# from utils.baidu_ai import my_audio
# from utils.baidu_ai import asr_json_bai
# from utils.baidu_ai import sizi
# from utils.baidu_ai import speak_audio
import my_audio
import asr_json_bai
import sizi
import speak_audio
from playsound import playsound
import os

# audio_name = input('请输入语音名称')
func_dic = {
    '1': '文字提问',
    '2': '语音提问',
    '3': '退出'
}


def get_data():
    while True:
        print("""
            '1': '文字提问',
            '2': '语音提问',
            '3': '退出',
            
        """)
        select_input = input('输入功能：')
        if select_input == '1':
            ret = input('请输入问题：')
            print('问题：%s' % ret)
            message, answer = sizi.get_answer(ret)
            print('答案：%s' % answer)
        elif select_input == '3':
            print('退出')
            break
        else:
            # 获取音频
            my_audio.get_audio('audio.pcm')
            # 转出文字
            ret = asr_json_bai.get_text('audio.pcm')
            print('问题：%s' % ret)
            message, answer = sizi.get_answer(ret)
            print('答案：%s' % answer)
            speak_audio.speak_au(answer)
            playsound('result.mp3')
        # os.system('result.mp3')


get_data()
